<?php

namespace Sensio\Bundle\HangmanBundle\Tests\Game;

use Sensio\Bundle\HangmanBundle\Game\Game;

class GameTest extends \PHPUnit_Framework_TestCase
{

    /**
     * @dataProvider provideWords
     */
    public function testTryCorrectWord($word)
    {
        $game = new Game($word);
        $this->assertTrue($game->tryWord($word));
        $this->assertTrue($game->isWon());
        $this->assertTrue($game->isOver());
        $this->assertFalse($game->isHanged());
    }
    
    public function provideWords()
    {
        return array(
            array('php'),
            array('java'),
            array('airplaine'),
        );
    }
    
    public function testTryWrongWord()
    {
        $game = new Game("php");
        $this->assertFalse($game->tryWord("asp"));
        $this->assertFalse($game->isWon());
        $this->assertTrue($game->isOver());
        $this->assertTrue($game->isHanged());
        $this->assertSame(0, $game->getRemainingAttempts());
    }
    
    public function testTryNumber()
    {
        $this->setExpectedException('InvalidArgumentException');
        $game = new Game("php");
        $game->tryLetter(10);
    }

}